/*
 * @Author: your name
 * @Date: 2021-08-30 11:18:11
 * @LastEditTime: 2021-09-07 14:55:29
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \bigdate\src\setting\menuTerg.ts
 */
import { computed, unref, ref } from 'vue'
// asdasd
let menuTrigger = ref(false)
// 改变侧边栏
export function setTrigter():object {
    menuTrigger.value = !menuTrigger.value 
    const menuTriggers = computed(() => unref(menuTrigger.value))
    return {
        menuTriggers,
    }
}
// 右边抽屉
let visibleRefs = ref(false)
export function visibleRef(type:boolean):Object {
    visibleRefs.value = type 
    const visibleRefValue = computed(() => unref(visibleRefs.value))
    return {
        visibleRefValue,
    }
}

// 刷新路由
let reloadRefs = ref<Boolean>(true)
export function reloadRouter(params:Boolean):Object {
    reloadRefs.value = params 
    const reloadRefsValue = computed(() => unref(reloadRefs.value))
    return {
        reloadRefsValue,
    } 
}
// 路由导航
let routerRefs = ref(false)
export function routerTrigger() {
    routerRefs.value = !routerRefs.value 
    const routerRefsValue = computed(() => unref(routerRefs.value))
    return {
        routerRefsValue,
    } 
}

// 监听视口变化
let autoLayout = ref<Boolean>(true)
export const autoWindow = function () {
    // 初始化监听
    if (window.innerWidth < 600) {
        autoLayout.value = false
    }
    // 动态监听
    window.onresize = function () {
        autoLayout.value = true
    
        if (window.innerWidth < 600) {
            autoLayout.value = false
        }
    }
    const autoValue = computed(() => unref(autoLayout.value))
    return {
        autoValue,
    }
}
// 初始化状态
export const initConfig = () => {
    menuTrigger.value = false
    routerRefs.value = false
}